﻿
namespace Mulala.Cavan.Presentation.Admin.ViewModel
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Mulala.Cavan.Domain.MainBoundedContext.MarketModule;
    using Mulala.Cavan.Presentation.Seedwork;

    public class MarketStatisticsViewModelConverter
    {
        public static IList<IMarketStatisticsViewModel> Convert(IList<MarketStatistics> marketStatisticss)
        {
            IList<IMarketStatisticsViewModel> marketStatisticsViewModels = new List<IMarketStatisticsViewModel>();
            foreach (MarketStatistics ms in marketStatisticss)
            {
                IMarketStatisticsViewModel marketStatisticsViewModel = ModelFactory.CreateModel<IMarketStatisticsViewModel>();
                marketStatisticsViewModel.Item = ms;
                marketStatisticsViewModels.Add(marketStatisticsViewModel);
            }
            return marketStatisticsViewModels;
        }

        public static MarketStatistics Convert(IMarketStatisticsViewModel marketStatisticsViewModel)
        {
            marketStatisticsViewModel.Item.StatisticsType = (MarketStatisticsIdentifier.StatisticsType)marketStatisticsViewModel.StatisticsTypeForEdit;
            marketStatisticsViewModel.Item.Source = (MarketStatisticsIdentifier.Source)marketStatisticsViewModel.SourceForEdit;

            return marketStatisticsViewModel.Item;
        }
    }
}